//
//  LVViewFlowLayout.swift
//  PhotoBrowser
//
//  Created by 刘伟 on 16/4/27.
//  Copyright © 2016年 刘伟. All rights reserved.
//

import UIKit

class LVViewFlowLayout: UICollectionViewFlowLayout {

//    设置流水布局
    override func prepareLayout() {
        
//        1.定义常量
        let clos : CGFloat = 3
        let margin : CGFloat = 20
        
//        2.计算item宽高
        let itemWH : CGFloat = (UIScreen.mainScreen().bounds.width - (clos + 1) * margin) / clos
        
//        3.设置item宽高
        itemSize = CGSize(width: itemWH, height: itemWH)
        
//        4.间距设置
        minimumInteritemSpacing = margin
        minimumLineSpacing = margin
        
//        5.collectionView的内边距设置
        collectionView?.contentInset = UIEdgeInsets(top: margin + 64, left: margin, bottom: margin, right: margin)
    
    }
    
    
    
    
    
}




















